package com.aizuda.boot.modules.business.contract.controller;


import com.aizuda.boot.modules.business.contract.entity.dto.ContractModelAddDTO;
import com.aizuda.boot.modules.business.contract.entity.dto.ContractModelSortDTO;
import com.aizuda.boot.modules.business.contract.entity.dto.ContractModelUpdateDTO;
import com.aizuda.boot.modules.business.contract.dto.SingleResponse;
import com.aizuda.boot.modules.business.contract.entity.vo.ContractModelDetailShowDTO;
import com.aizuda.boot.modules.business.contract.entity.vo.ContractModelShowDTO;
import com.aizuda.boot.modules.business.contract.service.impl.ContractExe;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author sangyirong
 * @ClassName troller
 * @Version 1.0
 * @Date 2025/5/29 18:00
 */
@RestController
@RequestMapping("/contract/modules")
@Tag(name = "合同模块管理接口")
public class ContractModuleController {

    @Autowired
    private ContractExe contractExe;

    @Operation(summary = "获取合同模块列表")
    @GetMapping
    public SingleResponse<List<ContractModelShowDTO>> listContractModules() {
        return contractExe.listContractModules();
    }

    @Operation(summary = "新增合同模块")
    @PostMapping
    public SingleResponse createContractModule(@RequestBody ContractModelAddDTO contractModelAddDTO) {
        return contractExe.createContractModule(contractModelAddDTO);
    }

    @Operation(summary = "获取合同模块详情")
    @GetMapping("/{id}")
    public SingleResponse<ContractModelDetailShowDTO> getContractModuleById(@PathVariable Integer id) {
        return contractExe.getContractModuleById(id);
    }

    @Operation(summary = "编辑合同模块")
    @PutMapping("/{id}")
    public SingleResponse updateContractModule(@PathVariable Integer id, @RequestBody ContractModelUpdateDTO contractModelUpdateDTO) {
        return contractExe.updateContractModule(id, contractModelUpdateDTO);
    }

    @Operation(summary = "删除合同模块")
    @DeleteMapping("/{id}")
    public SingleResponse deleteContractModule(@PathVariable Integer id) {
        return contractExe.deleteContractModule(id);
    }

    @Operation(summary = "合同模块排序")
    @PutMapping("/sort")
    public SingleResponse sortContractModules(@RequestBody ContractModelSortDTO contractModelSortDTO) {
        return contractExe.sortContractModules(contractModelSortDTO);
    }

}
